package main

import (
	"fmt"
	"math"
	"math/rand"
	"time"
)

func main() {
	nan45 := math.IsNaN(4.5)
	fmt.Println("nan45 == ", nan45)

	ceil45 := math.Ceil(4.5)
	fmt.Println("ceil45 == ", ceil45)

	floor45 := math.Floor(4.5)
	fmt.Println("floor45 == ", floor45)

	//随机数
	for i := 0; i < 10; i++ {
		intn := rand.Intn(100)
		fmt.Println("获取10次随机数 intn == ", intn)
	}

	//动态随机数种子
	source := rand.NewSource(time.Now().UnixNano())
	nanoRand := rand.New(source)

	for i := 0; i < 10; i++ {
		intn := nanoRand.Intn(100)
		fmt.Println("时间戳种子产生的随机数 intn == ", intn)
	}

	rand.Seed(time.Now().UnixNano())
	for i := 0; i < 10; i++ {
		intn := rand.Intn(100)
		fmt.Println("直接seed时间戳种子,产生的随机数 intn == ", intn)
	}

	//获取m到n的随机数
	n := 100
	m := 50
	for i := 0; i < 10; i++ {
		intn := rand.Intn(n-m+1) + m
		fmt.Println("n到m 产生的随机数 intn == ", intn)
	}
}
